/**
 * Created by guosc on 2016/10/25 0025.
 */
define(["angular",
    "framework/utils/JSONPrettyFormat",
    'framework/dataGrid/DataGridModule',
    'framework/pagination/GillionPaginationModule',
    'framework/msg/GillionMsgModule'
], function (angular) {
    var ProjectEditModule = angular.module("ProjectEditModule", [
        'DataGridModule',
        'GillionPaginationModule',
        'GillionMsgModule']);
    ProjectEditModule.controller("ProjectEditController", function ($scope, Resource, $location, GillionMsg, GillionMsgService) {
        var Projects = Resource("/grule-manager/projects?$v_group_name=Project_Save");
        $scope.project = GillionMsgService.getInputData();
        if($scope.project==undefined){
            $scope.add=true;
        }else{
            $scope.add=false;
        }
        $scope.confirm = function () {
            angular.element('form[name="ProjectForm"]').scope().ProjectForm.verify().then(function(){
                Projects.create($scope.project, function (response) {
                    if (response.success) {
                        GillionMsgService.setOutputData(response);
                        GillionMsgService.close();
                    }
                })
            })
        };
        $scope.cancel = function () {
            GillionMsgService.close();
        }

    });

});